class Solution(object):
    def checkRecord(self, s):
        """
        :type s: str
        :rtype: bool
        """
        n = len(s)
        index = 0
        A_count = 0
        L_count = 0
        while index < n:
            if s[index] == 'A':
                A_count += 1
                if A_count >= 2:
                    return False
                L_count = 0
            if s[index] == 'P':
                L_count = 0
            if s[index] == 'L':
                L_count += 1
                if L_count >= 3:
                    return False
            index += 1
        return True


data = Solution()
s = "PPALLP"
print(data.checkRecord(s))
